package com.shop.web.shop;

import java.util.List;

import com.shop.shop.domain.ShopUserOrder;
import com.shop.shop.service.IShopUserOrderService;
import com.vip.common.annotation.Log;
import com.vip.common.core.controller.BaseController;
import com.vip.common.core.domain.AjaxResult;
import com.vip.common.core.page.TableDataInfo;
import com.vip.common.enums.BusinessType;
import com.vip.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 用户，订单关联Controller
 * 
 * @author
 */
@Api(tags = "用户，订单关联接口")
@RestController
@RequestMapping("/system/uorder")
public class ShopUserOrderController extends BaseController
{
    @Autowired
    private IShopUserOrderService shopUserOrderService;

    /**
     * 查询用户，订单关联列表
     */
    @ApiOperation(value = "查询用户，订单关联列表")
    @GetMapping("/list")
    public TableDataInfo list(ShopUserOrder shopUserOrder)
    {
        startPage();
        List<ShopUserOrder> list = shopUserOrderService.selectShopUserOrderList(shopUserOrder);
        return getDataTable(list);
    }

    /**
     * 导出用户，订单关联列表
     */
    @ApiOperation(value = "导出用户，订单关联列表")
    @Log(title = "用户，订单关联", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ShopUserOrder shopUserOrder)
    {
        List<ShopUserOrder> list = shopUserOrderService.selectShopUserOrderList(shopUserOrder);
        ExcelUtil<ShopUserOrder> util = new ExcelUtil<ShopUserOrder>(ShopUserOrder.class);
        return util.exportExcel(list, "用户，订单关联数据");
    }

    /**
     * 获取用户，订单关联详细信息
     */
    @ApiOperation(value = "获取用户，订单关联详细信息")
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId)
    {
        return AjaxResult.success(shopUserOrderService.selectShopUserOrderByUserId(userId));
    }

    /**
     * 新增用户，订单关联
     */
    @ApiOperation(value = "新增用户，订单关联")
    @Log(title = "用户，订单关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShopUserOrder shopUserOrder)
    {
        return toAjax(shopUserOrderService.insertShopUserOrder(shopUserOrder));
    }

    /**
     * 修改用户，订单关联
     */
    @ApiOperation(value = "修改用户，订单关联")
    @Log(title = "用户，订单关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShopUserOrder shopUserOrder)
    {
        return toAjax(shopUserOrderService.updateShopUserOrder(shopUserOrder));
    }

    /**
     * 删除用户，订单关联
     */
    @ApiOperation(value = "删除用户，订单关联")
    @Log(title = "用户，订单关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds)
    {
        return toAjax(shopUserOrderService.deleteShopUserOrderByUserIds(userIds));
    }
}
